package com.yunfeng.supercall.bean;

import java.io.Serializable;
import java.lang.reflect.Array;
import java.lang.reflect.Type;

import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.ly.quickdev.library.bean.BaseUserIface;
import com.yunfeng.supercall.R;
import com.yunfeng.supercall.activity.MainActivity;
import com.yunfeng.supercall.app.AppContext;

public class UserBean<T> extends ContactsBaseBean implements BaseUserIface,  Serializable {

	 public Class<T> kind;
	  private static final long serialVersionUID = 1L;
	 public UserBean(Class<T> clazz){
		  this.kind = clazz;
	 }
	 
	 public T[] getInstance(){
		  return (T[])Array.newInstance(kind, 5);
		 }
		 
	
	public final void setupUserView(View v) {
		TextView name = (TextView) v.findViewById(R.id.user_name);
		ImageView avatar = (ImageView) v.findViewById(R.id.avatar);
		TextView num = (TextView) v.findViewById(R.id.num);
		TextView lev = (TextView) v.findViewById(R.id.level);
		if (name != null) {
			name.setText(getNick_name());
			try {
				name.setTextColor(Color
						.parseColor(MainActivity.LEVEL_COLOR_MAPS.get(
								this.getSucolor() + "").getColor()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		AppContext.displayImgWithDefault(avatar, getPhoto());
		if (num != null) {
			num.setText(getSuperNumber());
		}
		if (lev != null) {
			lev.setText("等级：" + MainActivity.LEVEL_MAPS.get(getLevel() + ""));
			try {
				lev.setTextColor(Color.parseColor(MainActivity.LEVEL_COLOR_MAPS
						.get(this.getSucolor() + "").getColor()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	
	public UserBean() {
		
	}

	private String vo_id;

	private String address;
	private String card;// 身份证
	private double lat;
	private double lng;
	private int level;// 等级
	private String note;// 备注

	private int sex;
	private String vo_pass;
	private String password;
	private int calltime;

	
	
	public int getCalltime() {
		return calltime;
	}

	public void setCalltime(int calltime) {
		this.calltime = calltime;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public static final String RED = "#ff0000";

	public String getVo_id() {
		return vo_id;
	}

	public void setVo_id(String vo_id) {
		this.vo_id = vo_id;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getCard() {
		return card;
	}

	public void setCard(String card) {
		this.card = card;
	}

	public double getLat() {
		return lat;
	}

	public void setLat(double lat) {
		this.lat = lat;
	}

	public double getLng() {
		return lng;
	}

	public void setLng(double lng) {
		this.lng = lng;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public int getSex() {
		return sex;
	}

	public void setSex(int sex) {
		this.sex = sex;
	}

	@Override
	public String getUserCode() {
		// TODO Auto-generated method stub
		return getPhone();
	}

	public String getVo_pass() {
		return vo_pass;
	}

	public void setVo_pass(String vo_pass) {
		this.vo_pass = vo_pass;
	}

	@Override
	public String getUserPassWord() {
		// TODO Auto-generated method stub
		return null;
	}

	public int getContactsType() {
		// TODO Auto-generated method stub
		return 0;
	}

	/*@Override
	public JsonElement serialize(User message, Type type,
			JsonSerializationContext jsc) {
		// TODO Auto-generated method stub
		  JsonObject jsonObject = new JsonObject();
	        jsonObject.addProperty("address", message.getAddress());
	        jsonObject.addProperty("vo_pass", message.getVo_pass());
	        jsonObject.addProperty("card", message.getCard());
	        jsonObject.addProperty("vo_id", message.getVo_id());
	        
	        jsonObject.addProperty("note", message.getNote());
	        jsonObject.addProperty("calltime", message.getCalltime());
	        jsonObject.addProperty("lng", message.getLng());
	        jsonObject.addProperty("lat", message.getLat());
	        
	        jsonObject.addProperty("sex", message.getSex());
	        jsonObject.addProperty("level", message.getLevel());
	        jsonObject.addProperty("superNumber", message.getSuperNumber() + "");
	        jsonObject.addProperty("mMatchKeywords", message.getMatchKeywords() + "");
	        
	        jsonObject.addProperty("mNamePinyinUnits", message.getNamePinyinUnits() + "");
	        jsonObject.addProperty("nick_name", message.getNick_name());
	        jsonObject.addProperty("onlineday", message.getOnlineday());
	        jsonObject.addProperty("phone", message.getPhone());
	        
	        jsonObject.addProperty("photo", message.getPhoto());
	        jsonObject.addProperty("real_name", message.getReal_name());
	        jsonObject.addProperty("suid", message.getSuid());
	        jsonObject.addProperty("lastChatTime", message.getLastChatTime());
	        
	        jsonObject.addProperty("sucolor", message.getSucolor());
	        jsonObject.addProperty("type", message.getType());
	        jsonObject.addProperty("unread", false);
	        jsonObject.addProperty("unreadCount", message.getUnreadCount());
	        jsonObject.addProperty("unreadCount", message.getUserid());
	        
	        
		return jsonObject;
	}*/

}
